import 'package:flutter/material.dart';
import 'package:flutter_vant/component/toast.dart';
import 'package:flutter_vant/main.dart';
import 'package:simulator/components/DemoViewGroup/index.dart';

class ToastView extends HookWidget {
  const ToastView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    renderBase() {
      return IDemoData(title: '基础用法', children: [
        IDemoChildren(
            title: '文字提示',
            onClick: () {
              VanToast(context, VanToastOption(message: '提示内容'));
            }),
        IDemoChildren(
            title: '加载提示',
            onClick: () {
              VanToast.loading(
                  context,
                  VanToastOption(
                    message: '加载中...',
                  ));
            }),
        IDemoChildren(
            title: '成功提示',
            onClick: () {
              VanToast.success(
                  context,
                  VanToastOption(
                    message: '成功文案',
                  ));
            }),
        IDemoChildren(
            title: '失败提示',
            onClick: () {
              VanToast.fail(context, VanToastOption(message: '失败文案'));
            })
      ]);
    }

    // 自定义图标
    renderCustomIcon() {
      return IDemoData(title: '自定义图标', children: [
        IDemoChildren(
            title: '自定义图标',
            onClick: () {
              VanToast(
                  context, VanToastOption(message: '自定义图标', icon: Icons.abc));
            }),
        IDemoChildren(
            title: '自定义图片',
            onClick: () {
              VanToast(
                  context,
                  VanToastOption(
                      message: '自定义图片',
                      icon:
                          'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F512%2F0PQ2123I9%2F120PQ23I9-10-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1647589390&t=621c8c6b102067f52a45740e44a65d39'));
            }),
      ]);
    }

    // 自定义位置
    renderCustomPosition() {
      return IDemoData(title: '自定义位置', children: [
        IDemoChildren(
            title: '顶部展示',
            onClick: () {
              VanToast(
                  context,
                  VanToastOption(
                      message: '自定义图标', position: VanToastPosition.top));
            }),
        IDemoChildren(
            title: '底部展示',
            onClick: () {
              VanToast(
                  context,
                  VanToastOption(
                      message: '自定义图标', position: VanToastPosition.bottom));
            }),
      ]);
    }

    // 动态更新提示

    return HookView(
      title: 'Toast',
      child: DemoViewGroup(data: [
        // 基础用法
        renderBase(),
        // 自定义图标
        renderCustomIcon(),
        // 自定义位置
        renderCustomPosition(),
        // 动画更新提示
      ]),
    );
  }
}
